import type { PageParams } from "@/types/common"
import type { Role, RoleData, RoleDetail, RoleParams, RoleUserData } from "@/types/system"
import { request } from "@/utils/reuqest"

export const getJueSeListAPI = () => {
  return request<Role[]>('/park/sys/role','GET')
}

export const getTreeAPI = () => {
  return request<RoleData[]>('park/sys/permision/all/tree','GET')
}

/**
 * 查询当前角色详情-权限和分配人数
 * @returns
 */
export const getRoleDetailAPI = (roleId: number) =>{
  return request<RoleDetail>(`/park/sys/role/${roleId}`)
}

/**
 * 获取角色成员列表
 * @param roleId 角色id
 * @param params 分页参数
 * @returns 
 */
export const getRoleUserAPI = (roleId: number, params?: PageParams) => {
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`, 'GET', params)
}

// 新增角色
export const createRoleAPI = (data: RoleParams) => {
  return request('/park/sys/role','POST',data)
}




/**
 * 更改角色
 * @returns
 */
export const updateRoleAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'PUT',data)
}

/**
 * 删除角色
 * @param roleId 角色id
 * @returns
 */
export const delRoleUserAPI = (roleId: number) => {
  return request(`/park/sys/role/${roleId}`, 'DELETE')
}

